﻿using Anke.SHManage.MSSQLDAL.TJDAL;
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Anke.SHManage.Web.Reports
{
    public partial class TJ_BSXJKRSModeWebForm : System.Web.UI.Page
    {
        private string reportName;
      protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitPage();
            }
            else
            {
                reportName = Convert.ToString(ViewState["reportName"]);
            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindReportDataSource();
        }

        private void InitPage()
        {
            this.Years.Value = DateTime.Now.Year.ToString();
            reportName = Request.QueryString["ReportName"];
            ViewState["reportName"] = reportName;
            //this.Month.Text = DateTime.Now.Month.ToString();
            BindReportDataSource();
        }

        protected void BindReportDataSource()
        {
            string year = (this.Years.Value).ToString();
            //string month = (this.Month.Text).ToString();
            string start1 = year.ToString();

            this.ReportViewer1.LocalReport.DataSources.Clear();
            this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/" + reportName);
            Microsoft.Reporting.WebForms.ReportParameter st = new Microsoft.Reporting.WebForms.ReportParameter("StartTime", start1);      
            this.ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] {st});
            TJDAL dal = new TJDAL();
            switch (reportName)
            {
                case "TJ_BSXJKRS.rdlc":
                    this.Page.Title = "病史小讲课人数统计表";
                    DataTable dt1 = dal.Get_TJ_BSXJKRS(year);
                    this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetForTJ_BSXJKRS", dt1));            
                    break;
                case "TJ_BSXJKRY.rdlc":
                    this.Page.Title = "病史小讲课人员统计表";
                    DataTable dt2 = dal.Get_TJ_BSXJKRY(year);
                    this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetForTJ_BSXJKRY", dt2));
                    break;
                case "TJ_BLHGL.rdlc":
                    this.Page.Title = "病历合格率统计表";
                    DataTable dt3 = dal.Get_TJ_BLHGL(year);
                    this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetForTJ_BLHGL", dt3));
                    break;
                default:
                    break;
            }
            this.ReportViewer1.LocalReport.Refresh();

        }
    }
}